//
//  NetWorkTools.swift
//  WeiBoOfSwift
//
//  Created by aven wu on 22/04/2018.
//  Copyright © 2018 GML. All rights reserved.
//

import UIKit
import AFNetworking
// 方法一
/*
private let _NetWorkToolsSharedInstance = NetWorkTools()
class NetWorkTools: NSObject {
    class var sharedInstance : NetWorkTools {
        return _NetWorkToolsSharedInstance
    }
    
}
 */

// 方法二
/*
class NetWorkTools: AFHTTPSessionManager {
    // swift 中let是线程安全的
    static let instance:NetWorkTools = NetWorkTools()
    class func shareInstance() -> NetWorkTools {
        return instance
    }
}
 */
class NetWorkTools: AFHTTPSessionManager {
    // swift 中let是线程安全的
    static let tool:NetWorkTools = {
        let url = NSURL(string: "https://api.weibo.com/")
        let t = NetWorkTools(baseURL: url! as URL)
        // @"application/json", @"text/json", @"text/javascript
        t.responseSerializer.acceptableContentTypes = NSSet(objects: "application/json","text/json","text/javascript","text/plain") as! Set<String>
        return t
    }()
    
   class func shareNetWorkTools() -> NetWorkTools {
        
        return tool
    }
}

